<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>canvas</title>
  <style>
    canvas {
      box-shadow: 5px 5px 10px #CCC;
    }
  </style>
</head>

<body>
  <canvas id="canvas" width="500" height="500">
    你的浏览器太low了~
  </canvas>
  <script>

    window.onload = function () {

      var canvas = document.getElementById('canvas')
      if (canvas.getContext) {
        var cvsCtx = canvas.getContext('2d');
        // createRadialGradient(x1, y1, r1, x2, y2, r2)
        var rgd = cvsCtx.createRadialGradient(45, 45, 10, 52, 50, 30)
        rgd.addColorStop(0, '#A7D30C'); // 中间那个小圆心
        rgd.addColorStop(0.8, '#019F62');
        rgd.addColorStop(1, 'rgba(1,159,98,0)');

        cvsCtx.fillStyle = rgd;
        cvsCtx.fillRect(0, 0, 150, 150);
      } else {
        alert('你的浏览器太low了~')
      }
    }
  </script>

</body>

</html>